<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!doctype html>
<html>
<head>
<title>角色管理</title>
<%@ include file="../../../common/base.jsp" %>
</head>

<body id="body">
<!--head-->
<div id="head">
	<%@ include file="../../../common/head.jsp" %>
</div>
<!--head end-->
<!--container-->
<div id="container">
	<div id="pageId" style="display: none;">04-01-02</div>
		<!--sidebar-->
		<%@ include file="../../../common/menu.jsp" %>
	    <!--sidebar-->
    <!--main-->
    <div class="main">
    	<div class="location" style="background-position:22px -109px;">
        	系统管理<span>&gt;</span>角色管理
        </div>
        <!--content-->
        <div class="content">
        <div class="set_buttons">
            <button type="button" class="btn btn_add" onclick="javascript:window.location.href='${pageContext.request.contextPath}/roleManagement/showSaveOrUpdateRole?type=save'">添加</button>
        </div>
            <div id="tableResult">
            	<table class="table_type1">
	                <thead>
	                    <tr>
	                        <th>序号</th><th>角色名称</th><th>操作</th>
	                    </tr>
	                </thead>
	                <tbody id="bodyResult"></tbody>
	            </table>
            </div>
            <div class="page">
                	<div class="itemNum" >
		                    	显示：<select id="selItem">
		                    			<option selected="selected" id="20">20</option>
		                    			<option id="30">30</option>
		                    			<option id="40">40</option>
		                    			<option id="50">50</option>
		                    		</select>条，共 <a id="totalCount" onclick="javascript:void(0);" ></a> 条
		                    </div>
                    <ul class="pagination" id="pageCur"></ul>
                </div>
        </div>
        <!--content-->
        <!--foot-->
        <div id="foot">
        	<p>北京掌中彩信息科技有限公司  提供技术支持</p>
        </div>
        <!--foot-->
    </div>
    <!--main-->
</div>
<!--container-->
<script src="${pageContext.request.contextPath}/static/js/basic.js"></script>
<script type="text/javascript">
//加载ajax请求
function loadResult(page,numPerPage){
	loadResultPerfect(page,numPerPage,"roleManagement/queryRoleList","");
}

// 加载ajax返回结果
function loadTableResult(data){
	var jo = data.json;
	if(jo != '' && jo != null){
		for (var i = 0; i < jo.length; i++) {
			var delBtn = "";
			var roleName = jo[i].roleName;
			if (roleName!="admin") {
				delBtn = "<a href='javascript:del("+jo[i].roleId+");'>删除</a>";
			}
			var content = "<tr>"+
	                    	"<td>"+(i+1)+"</td><td>"+roleName+"</td><td><a href='roleManagement/showSaveOrUpdateRole?type=update&roleId="+jo[i].roleId+"&roleName="+encodeURI(encodeURI(jo[i].roleName))+"'>修改</a>&emsp;"+delBtn+"</td>"+
	                      "</tr>";
	        $("#bodyResult").append(content);
	    }
	}
}

function del(roleId){
	prompt.confirm("您确定要删除吗?",function(){
			$.ajax({
			   type: "POST",
			   url: "${pageContext.request.contextPath}/roleManagement/delete",
			   dataType:"json",
			   data: {
			   		roleId:roleId
			   },
			   success: function(data){
			   		prompt.alert(data.msg);
					if (data.errorCode=="0") {
						loadResult(1,$("#selItem").val());
					}
			   }
		});	
	});
}

//表格排序表头样式
$(document).ready(function(e) {
	loadResult(1,$("#selItem").val());
});

</script>
</body>
</html>